﻿using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using WpfApp54_绑定到数据对象.Model;

namespace WpfApp54_绑定到数据对象
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        User user = new User() { UserName = "admin", UserPwd = "1234" };

        public MainWindow()
        {
            InitializeComponent();
        }

        private void BtnSubmit_Click(object sender, RoutedEventArgs e)
        {
            if (sender == BtnSubmit)
            {
                //User user = new User();
                //user.UserName = TbUserName.Text;
                //user.UserPwd = TbUserPwd.Text;

                ////提交动作
                MessageBox.Show($"UserName:{user.UserName};UserPwd:{user.UserPwd}");
            }
            else if (sender == BtnModify)
            {
                user.UserName += "1";
                user.UserPwd += "2";
            }
        }

        private void BtnModify_Click(object sender, RoutedEventArgs e)
        {

        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            this.DataContext = user;
        }
    }
}